package pl.com.sthaether.mc.event;

import java.util.ArrayList;
import java.util.List;

public abstract class MCEventListener {

    private final String name;
    private List<MCEventType> interestedTypes;

    public MCEventListener(String name, List<MCEventType> interestedTypes) {
        this.name = name;
        this.interestedTypes = interestedTypes;
    }

    public MCEventListener(String name, MCEventType... interestedTypes) {
        this.name = name;
        this.interestedTypes = new ArrayList<>();
        for (MCEventType type : interestedTypes) {
            this.interestedTypes.add(type);
        }
    }

    public abstract void actionPerformed(MCEvent<?> action);

    public List<MCEventType> getInterestedTypes() {
        return interestedTypes;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MCEventListener) {
            return getName().equals(((MCEventListener) obj).getName());
        }
        return super.equals(obj);
    }
}
